home *** CD-ROM | disk | FTP | other *** search
/ The Programmer Disk / The Programmer Disk (Microforum).iso / xpro / basic1 / pro10 / glibdemo.bas < prev    next >
Encoding:
BASIC Source File  |  1989-04-01  |  29.1 KB  |  1,098 lines

  1. DECLARE FUNCTION xMenuChoice% (menu$(), Trow%, LCol%, NAttr%, Hattr%, title$, Mark%(), XtdChc%)
  2. DECLARE FUNCTION xToglMark% (Mark%(), item%, Qmark%, MaxMark%)
  3. ' GLIBDEMO version 2
  4. ' (C) Copyright 1988
  5. '
  6. ' Demo of some of the newer, more useful or more interesting
  7. ' routines from GLIB version 1.6.
  8. '
  9. ' Written by Gizmo Mike
  10. '
  11. ' NOTE: This should have started from the batch file for proper
  12. '       switch settings.
  13. ' QB glibdemo /l glib16 /cmd <scrfile> <3 or 4 fake switches>
  14.  
  15. DECLARE FUNCTION AttrMake% (fg%, bg%)
  16. DECLARE FUNCTION MenuChoice% (menu$(), Trow%, LCol%, NAttr%, Hattr%, title$, Mark%(), XtdChc%)
  17. DECLARE FUNCTION DIR% (mask$, BYVAL FilArryPtr)
  18. DECLARE FUNCTION CPUInfo% (model%, submodel%, BiosRev%, cpu%, ndp%)
  19. DECLARE FUNCTION DayOfYr%
  20. DECLARE FUNCTION FUniq% (fil$, attr%, handle%)
  21. DECLARE FUNCTION FClose% (handle%)
  22. DECLARE FUNCTION FCount% (mask$)
  23. DECLARE FUNCTION FReadArray% (SEG arry%, fhandle%, bytes%)
  24. DECLARE FUNCTION FExists% (fil$)
  25. DECLARE FUNCTION GetDrv% ()
  26. DECLARE FUNCTION KeyReady%
  27. DECLARE FUNCTION LCount% (buffer$, fhandle%)
  28. DECLARE FUNCTION MenuCtrl% ()
  29. DECLARE FUNCTION MHz%
  30. DECLARE FUNCTION PtrStat% (x%)
  31. DECLARE FUNCTION SysTicks&
  32. DECLARE FUNCTION VidType% ()
  33.  
  34. DECLARE SUB SaveScrn (SEG arry%)
  35. DECLARE SUB RestScrn (SEG arry%)
  36. DECLARE SUB DirF (mask$, SEG FilArryPtr AS ANY)
  37. DECLARE SUB PrintStatL (SEG MsgArray AS ANY, action%, attr%)
  38.  
  39. CLEAR
  40. DEFINT A-Z
  41. OPTION BASE 1
  42.  
  43.     CLS
  44.     Crt = VidType                  ' get type of display
  45.  
  46.     IF (Crt MOD 2 = 0) OR (Crt = 2) THEN    ' set colors based on CRT Type
  47.         fg = 7                     ' EGA mono, Mono, or VGA mono
  48.         fgh = 15                   ' use bland colors
  49.         fgw = 0
  50.         bgw = 7
  51.         NAttr = 112
  52.         Rattr = 7
  53.         cmode = 0
  54.         wattr2 = AttrMake(7, 0)             ' set up some attributes
  55.         wattr3 = AttrMake(0, 7)
  56.         wattr4 = AttrMake(7, 0)
  57.         wattr5 = AttrMake(0, 15)
  58.         wattr6 = AttrMake(15, 0)
  59.  
  60.     ELSE
  61.         fg = 3                     ' CGA, EGA or VGA
  62.         fgh = 14                   ' use less bland colors
  63.         fgw = 14
  64.         bgw = 4
  65.         NAttr = 78
  66.         Rattr = 14
  67.         cmode = 1
  68.         wattr2 = AttrMake(7, 1)             ' set up some attributes
  69.         wattr3 = AttrMake(1, 7)
  70.         wattr4 = AttrMake(0, 11)
  71.         wattr5 = AttrMake(3, 0)
  72.         wattr6 = AttrMake(5, 14)
  73.     END IF
  74.  
  75.     COLOR fg, 0
  76.  
  77.     TYPE struct                         ' type structure for DirF
  78.         s AS STRING * 12
  79.     END TYPE
  80.  
  81.     TYPE structa
  82.         ls AS STRING * 80
  83.     END TYPE
  84.  
  85.     REDIM menu$(28)                     ' string array of demo choices
  86.     REDIM Mark(28)                      ' allow marking of up to 5
  87.  
  88.     REDIM msg$(4)
  89.     msg$(1) = "Press any key to continue"
  90.     msg$(2) = "GLIB: The standard in QB Libraries"
  91.     msg$(3) = "This is a demo of TimeSquare"
  92.     msg$(2) = "GLIB: So much Power, so few $$$"
  93.  
  94.     'set up status line messages
  95.     REDIM SLine(2) AS structa
  96.     SLine(1).ls = "               Navigate with Cursor keys.   Select with [Enter]  "
  97.     SLine(2).ls = "    Mark up to 5 selections with [TAB] or [SpaceBar].    [Esc] Quits Demo"
  98.  
  99.  
  100.  
  101.     REDIM ScrText((7 * 2000) + 1)       ' up to 5 info screens
  102.  
  103.     REDIM ScrnArry(12001)               ' enough for 6 screens
  104.  
  105.     REDIM temp(10)                      ' for printing GLIB returns in a loop
  106.  
  107.     REDIM Arg$(10)                      ' storage for parsed command line
  108.     NumArgs = 0
  109.     CALL cmdline(Arg$(), NumArgs)       ' get command line arguments
  110.  
  111.     IF (NumArgs = 0) OR (FExists(Arg$(1)) = 0) THEN
  112.         ScrFil$ = "ScrLib.DAT"
  113.         IF FExists(ScrFil$) = 0 THEN
  114.             GOSUB HowToRunDemo
  115.             SYSTEM
  116.         END IF
  117.     ELSE
  118.         ScrFil$ = Arg$(1)
  119.         ScrNum = 0                      ' screen to load
  120.     END IF
  121.  
  122.     ' the demo selections
  123.     DATA Other InfoSoft Items, Boxes, Chirp, CmdLine, Date / DFRMAT, DIR
  124.     DATA DrvSpace, DayOfYr, ErrorMessage, FExists, FlexMenu, FUniq, GetCH
  125.     DATA LCount, MenuCtrl, ProperCase, Printer Routines (4), Painter
  126.     DATA QPrint, SysInfo Routines, Scroll/Scroller, TFrmat/Systime
  127.     DATA Save/Rest Scrn, Windows, VidON / VidOFF, Read / Write Array
  128.     DATA Read / Write String, QUIT Demo (or [Esc])
  129.  
  130.     FOR x = 1 TO 28                     ' build the main menu
  131.         READ menu$(x)
  132.     NEXT x
  133.  
  134.     FOR x = 1 TO 3
  135.         ScrNum = x                      ' set screen to load
  136.         ScrPOS = ((x - 1) * 2000) + 1   ' array position to load to
  137.         GOSUB LoadScrn
  138.     NEXT x
  139.  
  140.     FOR x = 1 TO 3
  141.         ScrOffs = ((x - 1) * 2000) + 1  ' set offset pointer to array
  142.         CALL RestScrn(ScrText(ScrOffs)) ' display screen
  143.         x$ = INPUT$(1)                  ' eat key press
  144.     NEXT x
  145.  
  146.     title$ = " GLIB Demo "              ' FlexMenu title
  147.     First = LBOUND(menu$)               ' first possible selection
  148.     Last = UBOUND(menu$)                ' last (in case somebody messes with it)
  149.  
  150.  
  151.     DO
  152.         CLS
  153.         MarkedItem = 0                  ' reset flags
  154.         ArrayPOS = 0
  155.         XtdChc = 5                      ' how many marks to allow
  156.         REDIM Mark(Last)                ' erase old marks
  157.  
  158.         CALL PrintStatL(SLine(1), 0, 112)
  159.  
  160.         item = MenuChoice%(menu$(), -1, -1, NAttr%, Rattr%, title$, Mark%(), XtdChc%)
  161.  
  162.         IF XtdChc <> 27 THEN
  163.             FOR i = First TO Last       ' check for marked items
  164.                 IF Mark(i) THEN
  165.  
  166.                     item = i
  167.                     MarkedItem = 1
  168.                     IF (item < Last + 1) THEN
  169.                         GOSUB ExecItem
  170.                     END IF
  171.  
  172.                 END IF
  173.             NEXT i
  174.  
  175.             IF MarkedItem = 0 THEN
  176.                 GOSUB ExecItem
  177.             END IF
  178.         END IF
  179.  
  180.     LOOP UNTIL (XtdChc = 27) OR (item = Last + 1)
  181.  
  182.     ' closing sequence
  183.     CLS
  184.  
  185.     ScrNum = 1                     ' set screen to load
  186.     ScrPOS = 1
  187.     GOSUB LoadScrn
  188.     CALL RestScrn(ScrText(1))
  189.  
  190.     msg$(1) = " Place your GLIB order now!  "          ' change final msgs
  191.     msg$(3) = " Place your GLIB order now!  "
  192.     LOCATE 24, 3
  193.     PRINT SPACE$(60);
  194.  
  195.     CALL TimeSquare(msg$(), 24, 23, NAttr, 0)
  196.  
  197.     LOCATE 24, 3
  198.     PRINT SPACE$(60);
  199.     LOCATE 23, 1
  200.  
  201. SYSTEM
  202.  
  203. ExecItem:
  204.     IF item > 20 THEN item = item + 1
  205.  
  206.     CLS
  207.  
  208.     DoFade = 0
  209.  
  210.     ScrNum = item + 3                   ' adjust for logo etc
  211.     ScrPOS = 1                          ' adjust for OTHER INFO
  212.     GOSUB LoadScrn
  213.  
  214.     'IF item <> 23 THEN
  215.     CALL RestScrn(ScrText(ScrPOS))
  216.     'END IF
  217.  
  218.     SELECT CASE item
  219.         CASE 0, 1, 11
  220.  
  221.         CASE 2
  222.             x$ = INPUT$(1)
  223.             GOSUB BoxDemo
  224.  
  225.         CASE 3
  226.             GOSUB ChirpDemo
  227.  
  228.         CASE 4
  229.             GOSUB CmdLDemo
  230.  
  231.         CASE 5
  232.             GOSUB DateStuff
  233.  
  234.         CASE 6
  235.             x$ = INPUT$(1)
  236.             GOSUB DirDemo
  237.  
  238.         CASE 7
  239.             GOSUB DrvSpaceDemo
  240.  
  241.         CASE 8
  242.             GOSUB DayYrDemo
  243.  
  244.         CASE 9
  245.             GOSUB ErrMsgDemo
  246.  
  247.         CASE 10
  248.             GOSUB ExistDemo
  249.  
  250.         CASE 12
  251.             GOSUB UniqDemo
  252.  
  253.         CASE 13
  254.             GOSUB GetChDemo
  255.     
  256.         CASE 14
  257.             GOSUB LcountDemo
  258.  
  259.         CASE 15
  260.             GOSUB MenuCtrlDemo
  261.  
  262.         CASE 16
  263.             GOSUB PCaseDemo
  264.  
  265.         CASE 17
  266.             GOSUB PtrDemo
  267.  
  268.         CASE 18
  269.             x$ = INPUT$(1)
  270.             GOSUB PaintDemo
  271.  
  272.         CASE 19
  273.             x$ = INPUT$(1)
  274.             GOSUB QPrintDemo
  275.  
  276.         CASE 20
  277.             speed = MHz / 100       ' do test while reading screen
  278.             x$ = INPUT$(1)
  279.             ScrNum = ScrNum + 1     ' adjust for logo etc
  280.             ScrPOS = 2              ' adjust for OTHER INFO
  281.             GOSUB LoadScrn
  282.  
  283.             CALL RestScrn(ScrText(ScrPOS))
  284.  
  285.             GOSUB SysInfoDemo
  286.  
  287.  
  288.         CASE 22
  289.             x$ = INPUT$(1)
  290.             GOSUB ScrlDemo
  291.  
  292.         CASE 23
  293.             GOSUB TimeDemo
  294.  
  295.         CASE 24
  296.             x$ = INPUT$(1)
  297.             ScrNum = ScrNum + 1          ' adjust for logo etc
  298.             ScrPOS = 2                   ' adjust for OTHER INFO
  299.             GOSUB LoadScrn
  300.  
  301.             CALL RestScrn(ScrText(ScrPOS))
  302.             x$ = INPUT$(1)
  303.             GOSUB SrWdwsDemo
  304.  
  305.  
  306.         CASE 25
  307.             x$ = INPUT$(1)
  308.             GOSUB SrWdwsDemo
  309.  
  310.  
  311.         CASE 26
  312.             x$ = INPUT$(1)
  313.             GOSUB VidDemo
  314.  
  315.         CASE 27, 28
  316.  
  317.         CASE ELSE
  318.                 
  319.     END SELECT
  320.  
  321.  
  322.     GOSUB ContPrompt
  323.     COLOR fg, 0
  324.  
  325. RETURN
  326.  
  327.  
  328.  
  329. '************* demo code ****************
  330. BoxDemo:
  331.     CLS
  332.     CALL Boxes(1, 1, 6, 25, 1, 7)
  333.     CALL MilliDelay(500)                ' pause long enough to appreciate
  334.     CALL Boxes(10, 1, 20, 45, 2, 78)
  335.     CALL MilliDelay(500)                ' otherwise all 7 pop up too fast
  336.     CALL Boxes(1, 41, 16, 80, 3, 3)
  337.     CALL MilliDelay(500)
  338.     CALL Boxes(16, 31, 25, 75, 7, 14)
  339.     CALL MilliDelay(500)
  340.     CALL Boxes(5, 15, 23, 35, 6, 3)
  341.     CALL MilliDelay(500)
  342.     CALL Boxes(5, 55, 13, 79, 5, 2)
  343.     CALL Delay18(2)
  344.     CALL Boxes(15, 5, 18, 65, 4, 2)
  345.     COLOR fgh, 0
  346.     LOCATE 17, 7
  347.     PRINT "Boxes can be placed anywhere and support 9 frame styles"
  348.     DoFade = 1
  349. RETURN
  350.  
  351.  
  352. ChirpDemo:
  353.     FOR x = 1 TO 5
  354.         LOCATE 13 + x, 5
  355.         IF x MOD 2 THEN
  356.             CALL Chirp(0)
  357.             PRINT "Ascending"
  358.         ELSE
  359.             CALL Chirp(1)
  360.             PRINT "Descending"
  361.         END IF
  362.         CALL Delay18(12)                ' about 3/4 sec
  363.     NEXT x
  364. RETURN
  365.  
  366.  
  367. CmdLDemo:
  368.     x$ = INPUT$(1)                      ' eat a key
  369.                     ' clear lower portion of screen
  370.     CALL Windows(9, 2, 20, 79, 0, 1, 0, 0, "")
  371.  
  372.     FOR x = 1 TO NumArgs
  373.         LOCATE 11 + x, 10
  374.         PRINT "Argument number "; x; ": "; Arg$(x)
  375.     NEXT x
  376.  
  377. RETURN
  378.  
  379.  
  380. DateStuff:
  381.     CALL date(mo, day, yr, dow)         ' get date variables
  382.     CALL dfrmat(mo, day, yr, nudat$)    ' format to string
  383.     COLOR fgh, 0
  384.     LOCATE 14, 28
  385.     PRINT DATE$
  386.     LOCATE 15, 33
  387.     PRINT nudat$
  388.     LOCATE 19, 55
  389.     PRINT mo; day; yr; dow              ' show DATE return
  390. RETURN
  391.  
  392. DirDemo:
  393.     mask$ = "*.bas"                     ' look for these files
  394.     cnt = FCount(mask$)
  395.  
  396.     IF cnt < 3 THEN
  397.         mask$ = "*.*"                   ' not enough files to be impressive
  398.         cnt = FCount(mask$)             ' try *.*
  399.     END IF
  400.  
  401.     REDIM FileList(cnt) AS struct       ' set up filelist as an array of
  402.                                         ' cnt size of TYPE struct which
  403.                                         ' contains only a Fixed Len Str
  404.                                         ' of 12 chars long.
  405.                                         ' - re structure 'STRUCT' as a string
  406.                                         ' 11 or 13 chars long and see what
  407.                                         ' happens.  The result is from the
  408.                                         ' unique way QB structures Fixed Length
  409.                                         ' Strings.
  410.  
  411.     CALL DirF(mask$, FileList(1))       ' fill the array with the found files
  412.     CLS                                 ' print them.
  413.  
  414.     COLOR fgh, 0
  415.     LOCATE 2, 25
  416.     PRINT cnt;
  417.     COLOR fg, bg
  418.     PRINT " Files Found in mask "; : COLOR fgh, 0: PRINT mask$
  419.     IF cnt > 51 THEN
  420.         COLOR 7, 0
  421.         PRINT TAB(20); "(Only the first 51 will be displayed.)"
  422.         cnt = 51
  423.     END IF
  424.  
  425.     y = 1
  426.     z = 1
  427.     col = 10
  428.     COLOR fg, 0
  429.  
  430.     rowcnt = (cnt \ 3)                       ' even number rows in display
  431.  
  432.  
  433.     FOR x = 1 TO rowcnt                 ' print them in reasonably orderly
  434.                                         ' fashion
  435.         FOR y = 1 TO 3
  436.             LOCATE 5 + x, 10 + ((y - 1) * 25)
  437.             PRINT z; FileList(z).s
  438.             z = z + 1
  439.         NEXT y
  440.  
  441.     NEXT x
  442.  
  443.     y = 1
  444.     LOCATE 5 + x, 10 + ((y - 1) * 25)
  445.  
  446.  
  447.     FOR q = z TO cnt
  448.         PRINT q; FileList(q).s; TAB(10 + (y * 25));
  449.     NEXT q
  450.             
  451. RETURN
  452.  
  453.  
  454. DrvSpaceDemo:
  455.     a = 0                               ' poll default drive
  456.     CALL drvspace(a, b, c, d)
  457.                                         ' interpet returns
  458.     TotSpace& = CLNG(a%) * CLNG(c%) * CLNG(d%)
  459.     FreeSpc& = CLNG(a%) * CLNG(c%) * CLNG(b%)
  460.  
  461.     COLOR fg                            ' display what we know
  462.     LOCATE 12, 28
  463.     PRINT TotSpace&; "bytes"
  464.     LOCATE 14, 28
  465.     PRINT FreeSpc&; "bytes"
  466. RETURN
  467.  
  468.  
  469. DayYrDemo:
  470.     LOCATE 10, 42
  471.     COLOR fgh, 0
  472.     PRINT DayOfYr                        ' no need to assign it
  473. RETURN
  474.  
  475.  
  476. ErrMsgDemo:
  477.     LOCATE 15, 10
  478.     LINE INPUT "", msg$
  479.     IF LEN(msg$) < 2 THEN
  480.         msg$ = " You entered no message "
  481.     END IF
  482.     CALL ErrorMessage(msg$, 16, NAttr, 1)
  483.     LOCATE 18, 20
  484.     PRINT "ErrorMessage can also be quiet:"
  485.     CALL MilliDelay(150)
  486.     CALL ErrorMessage(msg$, 19, NAttr, 0)
  487.     CALL Delay18(12)
  488. RETURN
  489.  
  490.  
  491. ExistDemo:
  492.     LOCATE 15, 10
  493.     fil$ = "GLIBDEMO.BAS"
  494.     PRINT fil$;
  495.     IF FExists(fil$) THEN               ' test it
  496.         PRINT " exists!"                ' print findings
  497.     ELSE
  498.         PRINT " is missing."
  499.     END IF
  500.  
  501.     LOCATE 16, 10
  502.     fil$ = "FOOBAR.EXE"
  503.     PRINT fil$;
  504.     IF FExists(fil$) THEN
  505.         PRINT " exists!"
  506.     ELSE
  507.         PRINT " is missing."
  508.     END IF
  509. RETURN
  510.  
  511.  
  512. UniqDemo:
  513.     fil$ = "\" + SPACE$(63)             ' storage for return
  514.     errc = FUniq(fil$, 0, uh)           ' 0 = normal attribute
  515.     errc = FClose(uh)                   ' close the file
  516.     LOCATE 20, 15
  517.  
  518.     PRINT "Were I to need a scratch file, I could use ";
  519.     COLOR fgh, 0
  520.     fil$ = LTRIM$(RTRIM$(fil$))
  521.     PRINT fil$                          ' print significant part of temp file
  522.     KILL fil$
  523. RETURN
  524.  
  525.  
  526. GetChDemo:
  527.     ky$ = " "
  528.     LOCATE 24, 20
  529.     PRINT "Understand the idea here (Y/N)?        ";
  530.     CALL getch("YN", ky$)               ' only Y or N will be acted upon
  531.     LOCATE 24, 10
  532.     PRINT SPACE$(40);                   ' erase prompt
  533. RETURN
  534.  
  535.  
  536. LcountDemo:
  537.     fil$ = "GLIB16.DOC"                 ' target file
  538.     LOCATE 21, 5
  539.     PRINT fil$;
  540.  
  541.     IF FExists(fil$) THEN               ' can we access it?
  542.         ff = FREEFILE
  543.         OPEN fil$ FOR INPUT AS #ff      ' open it
  544.         ffh = FILEATTR(ff, 2)           ' convert to handle
  545.         t! = TIMER                      ' start timer
  546.  
  547.         ' check out the self destructing buffer used here
  548.         NumLines = LCount(SPACE$(4096), ffh)
  549.  
  550.         ' a second pass on this will show a LOT faster time
  551.         PRINT " has"; NumLines; "lines and I took "; TIMER - t!; " secs to count them!"
  552.         CLOSE #ff                       ' close the file
  553.     ELSE
  554.         PRINT " does not exist!"
  555.     END IF
  556.  
  557.     fil$ = "GLIBDEMO.BAS"
  558.     LOCATE 22, 5
  559.     PRINT fil$;
  560.  
  561.     IF FExists(fil$) THEN
  562.         ff = FREEFILE
  563.         OPEN fil$ FOR INPUT AS #ff
  564.         ffh = FILEATTR(ff, 2)
  565.         t! = TIMER
  566.  
  567.         NumLines = LCount(SPACE$(4096), ffh)
  568.         PRINT " has"; NumLines; "lines and I took "; TIMER - t!; " to count them!"
  569.         CLOSE #ff
  570.     ELSE
  571.         PRINT " does not exist!"
  572.     END IF
  573.  
  574.  
  575. RETURN
  576.  
  577.  
  578. MenuCtrlDemo:
  579.     DO
  580.         LOCATE 20, 15
  581.         code = MenuCtrl                 ' get a F or nunber key
  582.         IF code <> 15 THEN
  583.             PRINT USING "You pressed [F-##] or the number ##"; code; code
  584.         END IF
  585.     LOOP UNTIL code = 15                ' escape quits
  586. RETURN
  587.  
  588.  
  589. PCaseDemo:
  590.     LOCATE 14, 5
  591.     LINE INPUT "", msg$                 ' get string
  592.     msg$ = LCASE$(msg$)                 ' convert to LCASE for PCase
  593.     CALL pcase(msg$)                    ' Make It Proper Case
  594.     PRINT "PCase returns: ";
  595.     COLOR fgh, 0
  596.     PRINT msg$                          ' print return
  597. RETURN
  598.  
  599.  
  600. PaintDemo:
  601.     CLS
  602.     FOR x = 1 TO 405                    ' print a test pattern
  603.         PRINT x;
  604.     NEXT
  605.  
  606.     CALL SaveScrn(ScrnArry(1))          ' save the test pattern
  607.     CALL RestScrn(ScrnArry(1))          ' restore it
  608.  
  609.     FOR x = 1 TO 35 STEP 5              ' the rainbow
  610.         CALL Painter(1, 1, 12, 40, x)
  611.         IF Crt <> 2 THEN                ' if CGA crt type then
  612.             CALL Delay18(3)             '  slow down demo for
  613.         END IF                          '  appreciation
  614.  
  615.         CALL Painter(12, 1, 25, 40, x + 1)
  616.         IF Crt <> 2 THEN
  617.             CALL Delay18(3)
  618.         END IF
  619.  
  620.  
  621.         CALL Painter(1, 41, 12, 80, x + 2)
  622.         IF Crt <> 2 THEN
  623.             CALL Delay18(3)
  624.         END IF
  625.  
  626.         CALL Painter(12, 41, 25, 80, x + 3)
  627.         IF Crt <> 2 THEN
  628.             CALL Delay18(3)
  629.         END IF
  630.  
  631.         CALL RestScrn(ScrnArry(1))      ' restore screen
  632.     NEXT x
  633.  
  634.     CALL RestScrn(ScrText(ScrPOS))      ' restore Syntax screen
  635.     CALL Painter(8, 1, 25, 80, 0)       ' make top part COLOR 0,0
  636.  
  637.     LOCATE 7, 5
  638.     PRINT "Painter can also be used to hide text as we have on this screen."
  639.     PRINT TAB(5); "Press any key to unhide it..."
  640.     
  641.     DO
  642.     LOOP UNTIL KeyReady
  643.  
  644.     CALL Painter(9, 1, 25, 80, 7)       ' convert to COLOR 7,0
  645.     DoFade = 1
  646.  
  647. RETURN
  648.       
  649. PtrDemo:
  650.     ky$ = " "
  651.     COLOR fgh, 0
  652.     LOCATE 18, 5
  653.     PRINT "Perform PrtScrn demo (Y/N)?"
  654.     CALL getch("YN", ky$)
  655.     IF ky$ = "Y" THEN
  656.         CALL prtscrn                    ' darn simple
  657.     END IF
  658.  
  659.     LOCATE 20, 5
  660.     PRINT "Initialize LPT1: ";
  661.     CALL PtrInit(1)                     ' legal printers are 1 to 4
  662.     
  663.     LOCATE 21, 5
  664.     COLOR fg, 0
  665.     PRINT "Checking status (wait a sec first): "
  666.     CALL Delay(2)                       ' wait for low tech item
  667.     stat = PtrStat(1)                   ' get status for prtr one
  668.     LOCATE 22, 5
  669.     PRINT "Printer is ";
  670.     COLOR fgh, 0
  671.  
  672.     IF stat THEN
  673.         PRINT "ready!"
  674.     ELSE
  675.         PRINT "not responding!"
  676.     END IF
  677. RETURN
  678.  
  679. QPrintDemo:                
  680.     CLS
  681.     pstart! = TIMER                     ' start QB QPRINT timer
  682.  
  683.     FOR z = 1 TO 10
  684.         FOR x = 1 TO 24                 ' fill screen with PRINT
  685.             PRINT STRING$(80, CHR$(47 + z))
  686.         NEXT x
  687.     NEXT z
  688.     pend! = TIMER                       ' halt timer
  689.  
  690.     CLS : BEEP                          ' let 'em know QPrint is on the way
  691.  
  692.     qstart! = TIMER                     ' start QPRINT timer
  693.     FOR z = 1 TO 10                     ' fill screen 10 times
  694.         FOR x = 1 TO 24
  695.             CALL QPrint(STRING$(80, CHR$(47 + z)), x, 1, fg%)
  696.         NEXT x
  697.     NEXT z
  698.     qend! = TIMER                       ' halt QPrint timer
  699.  
  700.     pelaps! = pend! - pstart!           ' calculate elapsed times
  701.     qelaps! = qend! - qstart!
  702.  
  703.     CLS : LOCATE 10, 1                  ' show results
  704.     PRINT "Elapsed time for PRINT "; pelaps!
  705.     PRINT "Elapsed time for QPRINT "; qelaps!
  706.  
  707. RETURN
  708.  
  709.  
  710. SysInfoDemo:    
  711.     FOR x = 1 TO 5                      ' initialze vars to 0
  712.        temp(x) = 0
  713.     NEXT x
  714.     CALL SysInfo(temp(1), temp(2), temp(3), temp(4), temp(5))
  715.     '             ram,     par,      ser     ega Mem  Vga flag
  716.  
  717.     COLOR fgh, 0
  718.     FOR x = 1 TO 3                      ' calling with array variables
  719.         LOCATE 5 + x, 20                ' makes printing easier
  720.         PRINT USING "###"; temp(x)
  721.     NEXT x
  722.  
  723.     LOCATE 9, 20
  724.     PRINT USING "### Kb"; temp(4);      ' Ega KB
  725.  
  726.     LOCATE 10, 20                       ' VGA flag
  727.     IF temp(4) THEN
  728.         PRINT "Yes"
  729.     ELSE
  730.         PRINT " NO"
  731.     END IF
  732.  
  733.     drv$ = CHR$(GetDrv) + ":"           ' get drive
  734.     CALL GetVerify(vflag)               ' get V Flag
  735.  
  736.     LOCATE 6, 68
  737.     PRINT drv$
  738.  
  739.     LOCATE 7, 68
  740.     IF vflag THEN
  741.         PRINT " ON"
  742.     ELSE
  743.         PRINT "OFF"
  744.     END IF
  745.  
  746.     FOR x = 1 TO 5                      ' clear out any old returns
  747.         temp(x) = 0
  748.     NEXT x
  749.  
  750.     CALL VidInfo(temp(1), temp(2), temp(3), temp(4), temp(5))
  751.     '             rows,    cols,    mode,    page,   page size
  752.  
  753.     LOCATE 14, 65
  754.     SELECT CASE Crt                     ' crt determined at prog start
  755.         CASE 0
  756.             PRINT "MONO"
  757.         CASE 1
  758.             PRINT "HERC/HGC+"
  759.         CASE 1
  760.             PRINT "HERC InColor"
  761.         CASE 3
  762.             PRINT "CGA"
  763.         CASE 4
  764.             PRINT "EGA Mono"
  765.         CASE 5
  766.             PRINT "EGA Color"
  767.         CASE 6
  768.             PRINT "VGA Mono"
  769.         CASE 7
  770.             PRINT "VGA Color"
  771.         CASE ELSE
  772.             PRINT "unknown!"
  773.     END SELECT
  774.  
  775.     FOR x = 1 TO 5
  776.         LOCATE 14 + x, 65
  777.         PRINT USING "####"; temp(x)
  778.         temp(x) = 0                     ' clear for next call while printing
  779.     NEXT x
  780.  
  781.     errc = CPUInfo(temp(1), temp(2), temp(3), temp(4), temp(5))
  782.     '               Model,  Sub Mod, BiosRev,   cpu,    ndp
  783.  
  784.  
  785.     FOR x = 1 TO 3
  786.         LOCATE 13 + x, 20
  787.         IF (errc <> 0) AND (x > 1) THEN  ' if ERRC is set, SubMdl and BRev
  788.             PRINT "n/a"                  ' not supported
  789.         ELSE
  790.             PRINT USING "####"; temp(x)  ' Model is ok even if Errc
  791.         END IF
  792.     NEXT x
  793.  
  794.     LOCATE 19, 20
  795.     IF temp(4) < 80 THEN                ' print CPU type
  796.         PRINT USING " NEC V-##"; temp(4)
  797.     ELSE
  798.         PRINT USING " INTEL 80###"; temp(4)
  799.     END IF
  800.  
  801.     LOCATE 18, 20                       ' print Math coprocessor type
  802.     IF temp(5) THEN
  803.         PRINT USING " 80###"; temp(5)
  804.     ELSE
  805.         PRINT " none"
  806.     END IF
  807.  
  808.     LOCATE 21, 20                       ' speed was calculated while waiting
  809.                                         ' for keypress - see main loop
  810.     PRINT USING " ##.# MHz"; speed
  811. RETURN
  812.  
  813.  
  814. ScrlDemo:
  815.     COLOR fg, 0                        ' QPRINT a test pattern
  816.     FOR x = 1 TO 24
  817.         CALL QPrint(STRING$(80, CHR$(x + 96)), x, 1, 2)
  818.     NEXT x
  819.  
  820.  
  821.     BEEP
  822.     CALL SaveScrn(ScrnArry(1))          ' save the test pattern
  823.     COLOR fgh, 0
  824.  
  825.     FOR x = 1 TO 15                           ' print the text at the
  826.         CALL ScrollU(5, 20, 19, 59, fg, 1)    '  same line, let SCROLL
  827.         LOCATE 19, 22                         '  move the text up the screen
  828.         PRINT "Scroll Up Line # "; x;
  829.     NEXT x
  830.  
  831.     COLOR fgh, 0
  832.     LOCATE 15, 44: PRINT "Slow now, w/"
  833.     LOCATE 16, 44: PRINT "frame (from Boxes)!"
  834.  
  835.     GOSUB ContPrompt                    ' wait for you to catch up
  836.  
  837.     CALL RestScrn(ScrnArry(1))          ' restore test pattern
  838.  
  839.     CALL Boxes(5, 28, 17, 52, 6, fgh)
  840.  
  841.     COLOR fg, 0
  842.     FOR x = 1 TO 15        ' loop for 15 lines
  843.         CALL ScrollD(6, 30, 16, 50, fhg, 1)     '   scroll down a line
  844.         LOCATE 6, 31                            '   at top of window,....
  845.  
  846.         IF cmode THEN
  847.             COLOR x, 0
  848.         ELSE
  849.             COLOR 15, 0
  850.         END IF
  851.         PRINT "Scroll Dn Line #"; x;              '   print the message
  852.         CALL MilliDelay(500)                      '   waitasec
  853.     NEXT x
  854.  
  855.     BEEP
  856.  
  857.     CLS
  858.     LOCATE 10, 22
  859.     PRINT "Now, shifting the screen using SCROLLER."
  860.  
  861.     GOSUB ContPrompt
  862.  
  863.     CALL RestScrn(ScrnArry(1))          ' restore test pattern
  864.     BEEP
  865.  
  866.     FOR x = 1 TO 6
  867.          CALL scroller(40)              ' scroll L/R with delay
  868.          CALL MilliDelay(500)
  869.          CALL scroller(-40)
  870.          CALL MilliDelay(500)
  871.     NEXT x
  872.     CALL Delay(1)
  873.  
  874.     CALL RestScrn(ScrnArry(1))          ' restore test pattern
  875.  
  876.     BEEP
  877.     FOR x = 1 TO 80                     ' more
  878.         CALL scroller(-1)
  879.     NEXT x
  880.     SOUND 1200, .75
  881.     LOCATE 15, 25
  882.     PRINT "Scrolled lines are lost."
  883.  
  884.     CALL Delay(1)
  885.     LOCATE 16, 30
  886.     PRINT "Forever"
  887. RETURN
  888.  
  889.  
  890. TimeDemo:
  891.      CALL TFrmat(atime$, 1)             ' format with
  892.      CALL TFrmat(btime$, 0)             ' and without am/pm label
  893.      CALL SysTime(h, m, s, hh)          ' get low level time
  894.  
  895.      COLOR fgh, 0
  896.      LOCATE 15, 31
  897.      PRINT TIME$                        ' print BASIC version
  898.      LOCATE 16, 32
  899.      PRINT btime$                       ' print ours
  900.      LOCATE 16, 50
  901.      PRINT atime$                       ' and ours
  902.  
  903.      LOCATE 19, 55
  904.      PRINT h; m; s; hh                  ' and low level time
  905.      LOCATE 22, 25
  906.      PRINT SysTicks&
  907. RETURN
  908.  
  909.  
  910. SrWdwsDemo:
  911. '<<<<
  912.     CALL SaveScrn(ScrnArry(1))          ' now we have the screen with text
  913.                                         ' captured in array
  914.  
  915.                                         ' window that Grows and Chirps
  916.     CALL Windows(2, 2, 15, 55, 1, 1, 1, NAttr%, "Gro & SFX")
  917.  
  918.     IF Crt <> 2 THEN
  919.         CALL MilliDelay(250)            ' pause a bit if NOT CGA
  920.         LOCATE 8, 5
  921.         COLOR fgw, bgw                  ' so wdws appear individually
  922.         PRINT "There is a one quarter second delay"
  923.         LOCATE , 5
  924.         PRINT "between each window call for effect."
  925.         LOCATE , 5
  926.         PRINT "Untethered, they are even faster!"
  927.     END IF
  928.  
  929.     CALL SaveScrn(ScrnArry(2001))       ' captured one with window one on it
  930.  
  931.  
  932.                                         ' do a window, save the display, then
  933.                                         ' pause for fast CRTs
  934.     CALL Windows(12, 5, 23, 30, 0, 0, 2, wattr2%, "No Gro, No SFX")
  935.     CALL SaveScrn(ScrnArry(4001))
  936.     IF Crt <> 2 THEN
  937.         CALL MilliDelay(250)
  938.     END IF
  939.  
  940.  
  941.     CALL Windows(2, 42, 13, 75, 0, 1, 3, wattr3%, "SFX Only")
  942.     CALL SaveScrn(ScrnArry(6001))
  943.     IF Crt <> 2 THEN
  944.         CALL MilliDelay(250)
  945.     END IF
  946.  
  947.  
  948.     CALL Windows(5, 52, 23, 75, 1, 0, 0, wattr4%, "Gro Only")
  949.     CALL SaveScrn(ScrnArry(8001))
  950.     IF Crt <> 2 THEN
  951.         CALL MilliDelay(250)
  952.     END IF
  953.  
  954.  
  955.     CALL Windows(15, 32, 24, 52, 1, 1, 2, wattr5%, "Gro & SFX")
  956.     CALL SaveScrn(ScrnArry(10001))
  957.     IF Crt <> 2 THEN
  958.         CALL MilliDelay(250)
  959.     END IF
  960.  
  961.  
  962.     CALL Windows(2, 2, 6, 22, 0, 1, 3, wattr6%, "SFX Only")
  963.     CALL SaveScrn(ScrnArry(12001))
  964.     CALL MilliDelay(250)
  965.  
  966.  
  967.     COLOR fgh, 1
  968.     LOCATE 13, 6
  969.     PRINT " With Save / RestScrn "
  970.     LOCATE , 6
  971.     PRINT "we can back up one "
  972.     LOCATE , 6
  973.     PRINT "layer at a time..."
  974.     LOCATE , 6
  975.     PRINT "I have added a .5 sec"
  976.     LOCATE , 6
  977.     PRINT "delay so you see what"
  978.     LOCATE , 6
  979.     PRINT "is going on."
  980.  
  981.     CALL ClrKBd                         ' eat up type ahead
  982.     GOSUB ContPrompt
  983.  
  984.    
  985.     CALL RestScrn(ScrnArry(10001))      ' pop back windows 1 at a time
  986.     CALL MilliDelay(500)
  987.  
  988.     CALL RestScrn(ScrnArry(8001))
  989.     CALL MilliDelay(500)
  990.  
  991.     CALL RestScrn(ScrnArry(6001))
  992.     CALL MilliDelay(500)
  993.  
  994.     CALL RestScrn(ScrnArry(4001))
  995.     CALL MilliDelay(500)
  996.  
  997.     CALL RestScrn(ScrnArry(2001))
  998.     CALL MilliDelay(500)
  999.  
  1000.     CALL RestScrn(ScrnArry(1))          ' original screen
  1001.  
  1002.     COLOR 15, 1
  1003.     CALL Windows(12, 5, 23, 30, 0, 0, 2, wattr2%, "Window 2")
  1004.     LOCATE 13, 6
  1005.     PRINT "We still have each level"
  1006.     LOCATE , 6
  1007.     PRINT "of screen in memory, and"
  1008.     LOCATE , 6
  1009.     PRINT "can recall any level we"
  1010.     LOCATE , 6
  1011.     PRINT "choose! "
  1012.     LOCATE , 6
  1013.     PRINT "Let's peel them back "
  1014.     LOCATE , 6
  1015.     PRINT "with sound."
  1016.  
  1017.     GOSUB ContPrompt
  1018.  
  1019.                                         ' compare this method with above
  1020.     FOR x = 10001 TO 1 STEP -2000
  1021.         CALL RestScrn(ScrnArry(x))
  1022.         CALL Chirp(0)
  1023.         CALL MilliDelay(500)
  1024.     NEXT x
  1025.  
  1026. RETURN
  1027.  
  1028.  
  1029. VidDemo:
  1030.    CALL vidoff
  1031.    ky$ = " "
  1032.    vdone = 0                              ' set loop indicator
  1033.    cy = 0
  1034.  
  1035.    DO UNTIL vdone
  1036.        CALL MilliDelay(1500)                ' delay 1.5 secs
  1037.        vky$ = INKEY$                        ' key waiting?
  1038.        IF vky$ > "" THEN                    '   yes we are done
  1039.            CALL vidon
  1040.            CALL pgetch(" Do it Again? ", 22, NAttr, "YN", ky$)
  1041.            LOCATE 22, 20
  1042.            PRINT SPACE$(50);
  1043.            IF ky$ = "N" THEN
  1044.                vdone = 1
  1045.            ELSE
  1046.                CALL vidoff
  1047.            END IF
  1048.        END IF
  1049.  
  1050.        IF cy MOD 2 = 0 THEN
  1051.            PLAY "L64O3AGE"              ' I'm bored
  1052.        ELSE
  1053.            SOUND 1200, .5               ' make some noise
  1054.        END IF
  1055.        cy = cy + 1
  1056.  
  1057.    LOOP
  1058. RETURN
  1059.  
  1060.  
  1061. MiscDemo:                               ' forgot what I was going to put here
  1062. RETURN
  1063.  
  1064.  
  1065. ' **************** demo program support functions  **************
  1066. LoadScrn:
  1067.     ScrF = FREEFILE                     ' get BAS File No
  1068.     OPEN ScrFil$ FOR INPUT AS #ScrF
  1069.     scrFHandle = FILEATTR(ScrF, 2)      ' convert to handle
  1070.  
  1071.     bytes = 4000                        ' 4000 bytes per screen
  1072.     seekPos& = CLNG(CLNG(ScrNum - 1) * 4000) + 1
  1073.     SEEK #ScrF, seekPos&                ' use QB to seek to right spot
  1074.     errc = FReadArray(ScrText(ScrPOS), scrFHandle, bytes)
  1075.     CLOSE #ScrF                         ' no reason to keep file open
  1076. RETURN
  1077.  
  1078.  
  1079. HowToRunDemo:
  1080.     CLS
  1081.     LOCATE 5, 5
  1082.     PRINT "Cannot find 'SCRLIB.DAT'"
  1083.     PRINT TAB(5); "This demo depends on an external set of screens that holds"
  1084.     PRINT TAB(5); "the various screen displays.  Restart the demo from the"
  1085.     PRINT TAB(5); "batch file provided or using the command line listed in the demo source."
  1086. RETURN
  1087.  
  1088. ContPrompt:
  1089.     SOUND 1200, .5
  1090.     CALL ClrKBd
  1091.     CALL TimeSquare(msg$(), 24, 25, NAttr, 0)
  1092.     CALL ClrKBd                    ' some people get impatient
  1093.     IF DoFade THEN
  1094.         CALL Fade
  1095.     END IF
  1096. RETURN
  1097.  
  1098.